| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var chai = require('chai'); |
||
| 15 | describe('Attr', function() { |
||
| 16 | before( function(done) { |
||
| 17 | Manager.instance.init() |
||
| 18 | .then(function () { |
||
| 19 | this.fixture = {} |
||
| 20 | done() |
||
| 21 | |||
| 22 | }.bind(this)) |
||
| 23 | }); |
||
| 24 | |||
| 25 | /** |
||
| 26 | * |
||
| 27 | * |
||
| 28 | */ |
||
| 29 | it('new attr', function() { |
||
| 30 | var attr = new cmsData.attr("article-abe-d20160920T125255138Z.shtml") |
||
| 31 | chai.expect(attr.str).to.not.be.undefined; |
||
|
|
|||
| 32 | chai.expect(attr.val.s).to.not.be.undefined; |
||
| 33 | chai.expect(attr.val.s).to.be.equal('d'); |
||
| 34 | }); |
||
| 35 | |||
| 36 | /** |
||
| 37 | * |
||
| 38 | * |
||
| 39 | */ |
||
| 40 | it('attr.remove', function() { |
||
| 41 | var attr = new cmsData.attr("article-abe-d20160920T125255138Z.html") |
||
| 42 | var filename = attr.remove() |
||
| 43 | chai.expect(filename).to.be.equal('article.html'); |
||
| 44 | }); |
||
| 45 | |||
| 46 | /** |
||
| 47 | * |
||
| 48 | * |
||
| 49 | */ |
||
| 50 | it('attr.getExtension', function() { |
||
| 51 | var attr = new cmsData.attr("article-abe-d20160920T125255138Z.html") |
||
| 52 | var extension = attr.getExtension() |
||
| 53 | chai.expect(extension).to.be.equal('html'); |
||
| 54 | }); |
||
| 55 | |||
| 56 | /** |
||
| 57 | * |
||
| 58 | * |
||
| 59 | */ |
||
| 60 | it('attr.insert', function() { |
||
| 61 | var attr = new cmsData.attr("article-abe-d20160920T125255138Z.html") |
||
| 62 | var extension = attr.insert('test') |
||
| 63 | chai.expect(extension).to.be.equal('article-abe-test.html'); |
||
| 64 | }); |
||
| 65 | }); |
||
| 66 |